<?php

namespace App\Http\Controllers\Home;

use DB;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class GradeController extends Controller
{   
    /**
     *更新僵尸游戏分数
     */
    public function postZombies(Request $req)
    {
        DB::table('user_games')->increment('user_djscount', 1, array('uid' => $req->user_id));
        $res = DB::table('user_games')->where('uid',$req->user_id)->first();
        if ($res->user_djshigh < $req->end_score) {
            DB::table('user_games')->where('uid',$req->user_id)->update(['user_djshigh'=>$req->end_score]);
        }
    }

    /**
     *更新别踩白块成绩
     */
    public function postSqual(Request $req)
    {
        DB::table('user_games')->increment('user_cbkcount', 1, array('uid' => $req->user_id));
        $res = DB::table('user_games')->where('uid',$req->user_id)->first();
        if ($res->user_cbkhigh < $req->end_score) {
            DB::table('user_games')->where('uid',$req->user_id)->update(['user_cbkhigh'=>$req->end_score]);
        }
    }


}

